import { ArtResponse, type ArtParams, type Channel, type ChannelsParams } from "@/types/http"
import request from "@/utils/request"

/**
 * 获取用户频道
 */
export const getUserChannelListApi = () => {
  return request<Channel>({
    method: 'get',
    url: '/user/channels'
  })
}

/**
 * 获取所有频道
 */
export const getAllChannelListApi = () => {
  return request<Channel>({
    method: 'get',
    url: '/channels'
  })
}

// 删除
export const delChannelApi = (id: number) => {
  return request<string>({
    method: 'delete',
    url: `/user/channels/${id}`
  })
}

// 新增
export const postChannelApi = (channels: ChannelsParams) => {
  return request<{
    channels: ChannelsParams
  }>({
    method: 'put',
    url: '/user/channels',
    data: {
      channels
    }
  })
}

// 获取文章列表
export const getArtListApi = (artParams: ArtParams) => {
  return request<ArtResponse>({
    method: 'get',
    url: '/articles',
    params: artParams
  })
}

